﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;
using QLChoDiaOc.Process;
using QLChoDiaOc.Forms;

namespace QLChoDiaOc
{
    /// <summary>
    /// Interaction logic for Main.xaml
    /// </summary>
    public partial class Main : RibbonWindow
    {
        SelectInfo _selectInfo = new SelectInfo();

        public static bool flat = false;
        public Main(string TenDangNhap)
        {
            InitializeComponent();

            App.Mainform = this;
            App.TenDangNhap = TenDangNhap;
            mainframe.NavigationService.Navigate(new Uri("Forms/FormAbout.xaml", UriKind.Relative));
            HienGiaoDien(App.TenDangNhap);
            // Insert code required on object creation below this point.
            //tabBaoCao.Visibility = Visibility.Collapsed;
        }
        
        private void btnDangNhap_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDangNhap.xaml", UriKind.Relative));
        }

        public void HienGiaoDien(string user)
        {
            
            //switch (user)
            //{
            //    case "user":
            //        //tabBaoCao.Visibility = Visibility.Collapsed;
            //        break;
            //    case "admin":
            //        tabBaoCao.Visibility = Visibility.Visible;
            //        //tabDangKy.Visibility = Visibility.Collapsed;
            //        mainframe.NavigationService.Navigate(new Uri("Forms/FormAbout.xaml", UriKind.Relative));
            //        break;
            //    default: break;

            if (user != "admin" && _selectInfo.SelectMaLoaiNV(user) == "LNVGU")
            {
                tabNghiepVu.Visibility = Visibility.Collapsed;
                tabNhanVien.Visibility = Visibility.Collapsed;
                tabBaoCao.Visibility = Visibility.Collapsed;
            }
            if (user != "admin" && _selectInfo.SelectMaLoaiNV(user) == "LNV6T")
            {
                tabDangKy.Visibility = Visibility.Collapsed;
                tabBaoCao.Visibility = Visibility.Collapsed;
                tabNhanVien.Visibility = Visibility.Collapsed;
                grpGiaHanPhieuThu.Visibility = Visibility.Collapsed;
                grpDsKhachHang.Visibility = Visibility.Collapsed;
                grpDsDiaOc.Visibility = Visibility.Collapsed;
                grpThayDoiQuyDinh.Visibility = Visibility.Collapsed;
                grpThongTinKhac.Visibility = Visibility.Collapsed;
            }
            if (user != "admin" && _selectInfo.SelectMaLoaiNV(user) == "LNV4P")
            {
                tabDangKy.Visibility = Visibility.Collapsed;
                tabNhanVien.Visibility = Visibility.Collapsed;
                grpDaChupHinh.Visibility = Visibility.Collapsed;
            }
        }

        private void btnGioiThieu_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormAbout.xaml", UriKind.Relative));
        }
        
        private void btnThongtinKhachHang_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDKNguoiBan.xaml", UriKind.Relative));
        }

        private void btnDangKyDiaOc_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/DangKyDiaOc.xaml", UriKind.Relative));
        }

        private void btnDangKyDichVu_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/DichVuQuangCao.xaml", UriKind.Relative));
        }

        private void btnXacNhanGiayTo_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormXacNhanGiayTo.xaml", UriKind.Relative));
        }

        private void btnLapPhieuThu_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormPhieuThu.xaml", UriKind.Relative));
        }

        private void btnGiaHanPhieuThu_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormGiaHanPhieuThu.xaml", UriKind.Relative));
        }

        private void btnDsKhachHang_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDanhSachNguoiBan.xaml", UriKind.Relative));
        }

        private void btnThongTinKhac_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormCacQuanLyKhac.xaml", UriKind.Relative));
        }

        private void btnDsDiaOc_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDanhSachDiaOc.xaml", UriKind.Relative));
        }

        private void btnThayDoiQuyDinh_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormThayDoiQuyDinh.xaml", UriKind.Relative));
        }

        private void btnDaChupHinh_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDaChupHinh.xaml", UriKind.Relative));
        }

        private void btnBaoCaoTiLeQuangCao_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormKHTheoMoiLoaiQC.xaml", UriKind.Relative));
        }

        private void btnDoanhThuTungThang_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormThongKeDoanhThuTungThang.xaml", UriKind.Relative));
        }

        private void btnNhanVien_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormDSNhanVien.xaml", UriKind.Relative));
        }

        private void btnLoaiNhanVien_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormLoaiNhanVien.xaml", UriKind.Relative));
        }

        private void btnNguoiDung_Click(object sender, RoutedEventArgs e)
        {
            if (App.TenDangNhap != "admin")
                mainframe.NavigationService.Navigate(new Uri("Forms/FormThongTinNguoiDung.xaml", UriKind.Relative));
            else
                mainframe.NavigationService.Navigate(new Uri("Forms/FormAbout.xaml", UriKind.Relative));
        }

        private void btnQcTheoThang_Click(object sender, RoutedEventArgs e)
        {
            mainframe.NavigationService.Navigate(new Uri("Forms/FormBCDVTungThang.xaml", UriKind.Relative));
        }

        private void mnuItDangXuat_Click(object sender, RoutedEventArgs e)
        {
            WinDangNhap _dangnhap = new WinDangNhap();
            _dangnhap.Show();
            this.Close();
        }
    }
}
